#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
    int n = 0;
    while (scanf("%d", &n) != EOF)
    {
        int sum = 0;
        for (int i = 1; i <= n; i++)
        {
            sum += 3 * i - 1;
        }
        printf("%d\n", sum);
    }
    return 0;
}